#include "../SerialPort/SerialPort.h"
#include <iostream>
#include <memory>
#include <synchapi.h>

const char *PortName{"\\\\.\\COM11"};

char InputData[MAX_DATA_LENGTH];

const char SendCmd[] = {0x16, 0x54, 0x0D};

int main() {
    std::shared_ptr<SerialPort> HoneyWell(new SerialPort(PortName));

    if (!HoneyWell->IsConnected()) {
        std::cout << "Connection break!" << std::endl;
        system("pause");
        return -1;
    }

    if (!HoneyWell->WriteSerialPort(SendCmd, MAX_DATA_LENGTH)) {
        std::cout << "Running WriteSerialPort failed!" << std::endl;
        system("pause");
        return -1;
    }

    while (0 == HoneyWell->ReadSerialPort(InputData, MAX_DATA_LENGTH)) {
        Sleep(50);
        if (!HoneyWell->IsConnected()) {
            std::cout << "Connection break!" << std::endl;
            system("pause");
            return -1;
        }
    }

    std::cout << InputData << std::endl;
    system("pause");
    return 0;
}